﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Microsoft.BizTalk.Bam.EventObservation;

namespace Locallab.Ack999Helper.BusinessContextReader
{
    public struct Activities
    {
        public const string EdiFileInformation = "EdiFileInformation";
        public const string InterChangeHeader = "InterChangeHeader";
        public const string EdiBusinessContext = "EdiBusinessContext";
    }

    #region Helper class for the EdiFileInformation BAM activity

    public class EdiFileInformation
    {
        public EdiFileInformation(string EdiFileInformationID)
        {
            _EdiFileInformationID = EdiFileInformationID;
        }

        public string ActivityID
        {
            get { return _EdiFileInformationID; }
        }

        // Begin the EdiFileInformation BAM activity
        public void BeginEdiFileInformationActivity()
        {
            // Begin the Activity using the passed identifier
            DirectEventStream es = Utility.GetEventStream();
            es.BeginActivity(ActivityName, _EdiFileInformationID);

        }

        // Write any data changes to the _EdiFileInformation activity
        // This must be called post any property changes
        public void CommitEdiFileInformationActivity()
        {
            // We need to provide the key/value pairs to the BAM API
            ArrayList al = new ArrayList();
            foreach (DictionaryEntry de in _activityItemHashtable)
            {
                al.Add(de.Key);
                al.Add(de.Value);
            }

            // Update the BAM Activity with all of the data
            DirectEventStream es = Utility.GetEventStream();
            es.UpdateActivity(ActivityName, _EdiFileInformationID, al.ToArray());

        }

        // End the EdiFileInformation BAM activity, no more changes will be permitted to this activity unless continuation is used
        public void EndEdiFileInformationActivity()
        {
            // End this activity, no more data can be added.
            DirectEventStream es = Utility.GetEventStream();
            es.EndActivity(ActivityName, _EdiFileInformationID);
        }

        // Add a reference from this activity to another activity
        public void AddReferenceToAnotherActivity(string OtherActivityName, string OtherActivityID)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _EdiFileInformationID, "Activity", OtherActivityName, OtherActivityID);
        }

        // Add a custom reference to this activity, this enables "data" to be attached to an activity such as a message body
        public void AddCustomReference(string referenceName, string referenceType, string referenceData, string longReferenceData)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _EdiFileInformationID, referenceName, referenceType, referenceData, longReferenceData);
        }


        public string FileID
        {
            set { _activityItemHashtable.Add(FileIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FileIDBAMFieldName]; }
        }

        public const string FileIDBAMFieldName = "FileID";

        public string FileName
        {
            set { _activityItemHashtable.Add(FileNameBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FileNameBAMFieldName]; }
        }

        public const string FileNameBAMFieldName = "FileName";

        public string Sender
        {
            set { _activityItemHashtable.Add(SenderBAMFieldName, value); }
            get { return (string)_activityItemHashtable[SenderBAMFieldName]; }
        }

        public const string SenderBAMFieldName = "Sender";

        public string Receiver
        {
            set { _activityItemHashtable.Add(ReceiverBAMFieldName, value); }
            get { return (string)_activityItemHashtable[ReceiverBAMFieldName]; }
        }

        public const string ReceiverBAMFieldName = "Receiver";

        public DateTime ReceiveDate
        {
            set { _activityItemHashtable.Add(ReceiveDateBAMFieldName, value); }
            get { return (DateTime)_activityItemHashtable[ReceiveDateBAMFieldName]; }
        }

        public const string ReceiveDateBAMFieldName = "ReceiveDate";

        public string SegmentDelimiter
        {
            set { _activityItemHashtable.Add(SegmentDelimiterBAMFieldName, value); }
            get { return (string)_activityItemHashtable[SegmentDelimiterBAMFieldName]; }
        }

        public const string SegmentDelimiterBAMFieldName = "SegmentDelimiter";

        public string ElementDelimiter
        {
            set { _activityItemHashtable.Add(ElementDelimiterBAMFieldName, value); }
            get { return (string)_activityItemHashtable[ElementDelimiterBAMFieldName]; }
        }

        public const string ElementDelimiterBAMFieldName = "ElementDelimiter";

        public string ComponentDelimiter
        {
            set { _activityItemHashtable.Add(ComponentDelimiterBAMFieldName, value); }
            get { return (string)_activityItemHashtable[ComponentDelimiterBAMFieldName]; }
        }

        public const string ComponentDelimiterBAMFieldName = "ComponentDelimiter";

        public const string ActivityName = "EdiFileInformation";
        private string _EdiFileInformationID = null;
        private Hashtable _activityItemHashtable = new Hashtable();
    }

    #endregion

    #region Helper class for the InterChangeHeader BAM activity

    public class InterChangeHeader
    {
        public InterChangeHeader(string InterChangeHeaderID)
        {
            _InterChangeHeaderID = InterChangeHeaderID;
        }

        public string ActivityID
        {
            get { return _InterChangeHeaderID; }
        }

        // Begin the InterChangeHeader BAM activity
        public void BeginInterChangeHeaderActivity()
        {
            // Begin the Activity using the passed identifier
            DirectEventStream es = Utility.GetEventStream();
            es.BeginActivity(ActivityName, _InterChangeHeaderID);

        }

        // Write any data changes to the _InterChangeHeader activity
        // This must be called post any property changes
        public void CommitInterChangeHeaderActivity()
        {
            // We need to provide the key/value pairs to the BAM API
            ArrayList al = new ArrayList();
            foreach (DictionaryEntry de in _activityItemHashtable)
            {
                al.Add(de.Key);
                al.Add(de.Value);
            }

            // Update the BAM Activity with all of the data
            DirectEventStream es = Utility.GetEventStream();
            es.UpdateActivity(ActivityName, _InterChangeHeaderID, al.ToArray());

        }

        // End the InterChangeHeader BAM activity, no more changes will be permitted to this activity unless continuation is used
        public void EndInterChangeHeaderActivity()
        {
            // End this activity, no more data can be added.
            DirectEventStream es = Utility.GetEventStream();
            es.EndActivity(ActivityName, _InterChangeHeaderID);
        }

        // Add a reference from this activity to another activity
        public void AddReferenceToAnotherActivity(string OtherActivityName, string OtherActivityID)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _InterChangeHeaderID, "Activity", OtherActivityName, OtherActivityID);
        }

        // Add a custom reference to this activity, this enables "data" to be attached to an activity such as a message body
        public void AddCustomReference(string referenceName, string referenceType, string referenceData, string longReferenceData)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _InterChangeHeaderID, referenceName, referenceType, referenceData, longReferenceData);
        }


        public string AuthorizationInformationQualifier
        {
            set { _activityItemHashtable.Add(AuthorizationInformationQualifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[AuthorizationInformationQualifierBAMFieldName]; }
        }

        public const string AuthorizationInformationQualifierBAMFieldName = "AuthorizationInformationQualifier";

        public string AuthorizationInformation
        {
            set { _activityItemHashtable.Add(AuthorizationInformationBAMFieldName, value); }
            get { return (string)_activityItemHashtable[AuthorizationInformationBAMFieldName]; }
        }

        public const string AuthorizationInformationBAMFieldName = "AuthorizationInformation";

        public string SecurityInformationQualifier
        {
            set { _activityItemHashtable.Add(SecurityInformationQualifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[SecurityInformationQualifierBAMFieldName]; }
        }

        public const string SecurityInformationQualifierBAMFieldName = "SecurityInformationQualifier";

        public string SecurityInformation
        {
            set { _activityItemHashtable.Add(SecurityInformationBAMFieldName, value); }
            get { return (string)_activityItemHashtable[SecurityInformationBAMFieldName]; }
        }

        public const string SecurityInformationBAMFieldName = "SecurityInformation";

        public string InterchangeSenderIDQualifier
        {
            set { _activityItemHashtable.Add(InterchangeSenderIDQualifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeSenderIDQualifierBAMFieldName]; }
        }

        public const string InterchangeSenderIDQualifierBAMFieldName = "InterchangeSenderIDQualifier";

        public string InterchangeSenderID
        {
            set { _activityItemHashtable.Add(InterchangeSenderIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeSenderIDBAMFieldName]; }
        }

        public const string InterchangeSenderIDBAMFieldName = "InterchangeSenderID";

        public string InterchangeReceiverIDQualifier
        {
            set { _activityItemHashtable.Add(InterchangeReceiverIDQualifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeReceiverIDQualifierBAMFieldName]; }
        }

        public const string InterchangeReceiverIDQualifierBAMFieldName = "InterchangeReceiverIDQualifier";

        public string InterchangeReceiverID
        {
            set { _activityItemHashtable.Add(InterchangeReceiverIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeReceiverIDBAMFieldName]; }
        }

        public const string InterchangeReceiverIDBAMFieldName = "InterchangeReceiverID";

        public string InterchangeDate
        {
            set { _activityItemHashtable.Add(InterchangeDateBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeDateBAMFieldName]; }
        }

        public const string InterchangeDateBAMFieldName = "InterchangeDate";

        public string InterchangeTime
        {
            set { _activityItemHashtable.Add(InterchangeTimeBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeTimeBAMFieldName]; }
        }

        public const string InterchangeTimeBAMFieldName = "InterchangeTime";

        public string InterchangeControlStandardsIdentifier
        {
            set { _activityItemHashtable.Add(InterchangeControlStandardsIdentifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeControlStandardsIdentifierBAMFieldName]; }
        }

        public const string InterchangeControlStandardsIdentifierBAMFieldName = "InterchangeControlStandardsIdentifier";

        public string InterchangeControlVersionNumber
        {
            set { _activityItemHashtable.Add(InterchangeControlVersionNumberBAMFieldName, value); }
            get { return (string)_activityItemHashtable[InterchangeControlVersionNumberBAMFieldName]; }
        }

        public const string InterchangeControlVersionNumberBAMFieldName = "InterchangeControlVersionNumber";

        public int InterchangeControlNumber
        {
            set { _activityItemHashtable.Add(InterchangeControlNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[InterchangeControlNumberBAMFieldName]; }
        }

        public const string InterchangeControlNumberBAMFieldName = "InterchangeControlNumber";

        public string AcknowledgmentRequested
        {
            set { _activityItemHashtable.Add(AcknowledgmentRequestedBAMFieldName, value); }
            get { return (string)_activityItemHashtable[AcknowledgmentRequestedBAMFieldName]; }
        }

        public const string AcknowledgmentRequestedBAMFieldName = "AcknowledgmentRequested";

        public string UsageIndicator
        {
            set { _activityItemHashtable.Add(UsageIndicatorBAMFieldName, value); }
            get { return (string)_activityItemHashtable[UsageIndicatorBAMFieldName]; }
        }

        public const string UsageIndicatorBAMFieldName = "UsageIndicator";

        public string FunctionalIdentifier
        {
            set { _activityItemHashtable.Add(FunctionalIdentifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FunctionalIdentifierBAMFieldName]; }
        }

        public const string FunctionalIdentifierBAMFieldName = "FunctionalIdentifier";

        public string FunctionalSenderCode
        {
            set { _activityItemHashtable.Add(FunctionalSenderCodeBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FunctionalSenderCodeBAMFieldName]; }
        }

        public const string FunctionalSenderCodeBAMFieldName = "FunctionalSenderCode";

        public string FunctionalReceiverCode
        {
            set { _activityItemHashtable.Add(FunctionalReceiverCodeBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FunctionalReceiverCodeBAMFieldName]; }
        }

        public const string FunctionalReceiverCodeBAMFieldName = "FunctionalReceiverCode";

        public string FunctionalReceivedDate
        {
            set { _activityItemHashtable.Add(FunctionalReceivedDateBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FunctionalReceivedDateBAMFieldName]; }
        }

        public const string FunctionalReceivedDateBAMFieldName = "FunctionalReceivedDate";

        public string FunctionalReceivedTime
        {
            set { _activityItemHashtable.Add(FunctionalReceivedTimeBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FunctionalReceivedTimeBAMFieldName]; }
        }

        public const string FunctionalReceivedTimeBAMFieldName = "FunctionalReceivedTime";

        public int FunctionalControlNumber
        {
            set { _activityItemHashtable.Add(FunctionalControlNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[FunctionalControlNumberBAMFieldName]; }
        }

        public const string FunctionalControlNumberBAMFieldName = "FunctionalControlNumber";

        public string ResponsibleAgency
        {
            set { _activityItemHashtable.Add(ResponsibleAgencyBAMFieldName, value); }
            get { return (string)_activityItemHashtable[ResponsibleAgencyBAMFieldName]; }
        }

        public const string ResponsibleAgencyBAMFieldName = "ResponsibleAgency";

        public string VersionCode
        {
            set { _activityItemHashtable.Add(VersionCodeBAMFieldName, value); }
            get { return (string)_activityItemHashtable[VersionCodeBAMFieldName]; }
        }

        public const string VersionCodeBAMFieldName = "VersionCode";

        public string FileID
        {
            set { _activityItemHashtable.Add(FileIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FileIDBAMFieldName]; }
        }

        public const string FileIDBAMFieldName = "FileID";

        public const string ActivityName = "InterChangeHeader";
        private string _InterChangeHeaderID = null;
        private Hashtable _activityItemHashtable = new Hashtable();
    }

    #endregion

    #region Helper class for the EdiBusinessContext BAM activity

    public class EdiBusinessContext
    {
        public EdiBusinessContext(string EdiBusinessContextID)
        {
            _EdiBusinessContextID = EdiBusinessContextID;
        }

        public string ActivityID
        {
            get { return _EdiBusinessContextID; }
        }

        // Begin the EdiBusinessContext BAM activity
        public void BeginEdiBusinessContextActivity()
        {
            // Begin the Activity using the passed identifier
            DirectEventStream es = Utility.GetEventStream();
            es.BeginActivity(ActivityName, _EdiBusinessContextID);

        }

        // Write any data changes to the _EdiBusinessContext activity
        // This must be called post any property changes
        public void CommitEdiBusinessContextActivity()
        {
            // We need to provide the key/value pairs to the BAM API
            ArrayList al = new ArrayList();
            foreach (DictionaryEntry de in _activityItemHashtable)
            {
                al.Add(de.Key);
                al.Add(de.Value);
            }

            // Update the BAM Activity with all of the data
            DirectEventStream es = Utility.GetEventStream();
            es.UpdateActivity(ActivityName, _EdiBusinessContextID, al.ToArray());

        }

        // End the EdiBusinessContext BAM activity, no more changes will be permitted to this activity unless continuation is used
        public void EndEdiBusinessContextActivity()
        {
            // End this activity, no more data can be added.
            DirectEventStream es = Utility.GetEventStream();
            es.EndActivity(ActivityName, _EdiBusinessContextID);
        }

        // Add a reference from this activity to another activity
        public void AddReferenceToAnotherActivity(string OtherActivityName, string OtherActivityID)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _EdiBusinessContextID, "Activity", OtherActivityName, OtherActivityID);
        }

        // Add a custom reference to this activity, this enables "data" to be attached to an activity such as a message body
        public void AddCustomReference(string referenceName, string referenceType, string referenceData, string longReferenceData)
        {
            // Add a reference to another activity
            DirectEventStream es = Utility.GetEventStream();
            es.AddReference(ActivityName, _EdiBusinessContextID, referenceName, referenceType, referenceData, longReferenceData);
        }


        public string FileID
        {
            set { _activityItemHashtable.Add(FileIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[FileIDBAMFieldName]; }
        }

        public const string FileIDBAMFieldName = "FileID";

        public int InterChangeControlNumber
        {
            set { _activityItemHashtable.Add(InterChangeControlNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[InterChangeControlNumberBAMFieldName]; }
        }

        public const string InterChangeControlNumberBAMFieldName = "InterChangeControlNumber";

        public int FunctionalControlNumber
        {
            set { _activityItemHashtable.Add(FunctionalControlNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[FunctionalControlNumberBAMFieldName]; }
        }

        public const string FunctionalControlNumberBAMFieldName = "FunctionalControlNumber";

        public int TransactionSetNumber
        {
            set { _activityItemHashtable.Add(TransactionSetNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[TransactionSetNumberBAMFieldName]; }
        }

        public const string TransactionSetNumberBAMFieldName = "TransactionSetNumber";

        public int StartIndex
        {
            set { _activityItemHashtable.Add(StartIndexBAMFieldName, value); }
            get { return (int)_activityItemHashtable[StartIndexBAMFieldName]; }
        }

        public const string StartIndexBAMFieldName = "StartIndex";

        public int EndIndex
        {
            set { _activityItemHashtable.Add(EndIndexBAMFieldName, value); }
            get { return (int)_activityItemHashtable[EndIndexBAMFieldName]; }
        }

        public const string EndIndexBAMFieldName = "EndIndex";

        public string BusinessIDQualifier
        {
            set { _activityItemHashtable.Add(BusinessIDQualifierBAMFieldName, value); }
            get { return (string)_activityItemHashtable[BusinessIDQualifierBAMFieldName]; }
        }

        public const string BusinessIDQualifierBAMFieldName = "BusinessIDQualifier";

        public string BusinessID
        {
            set { _activityItemHashtable.Add(BusinessIDBAMFieldName, value); }
            get { return (string)_activityItemHashtable[BusinessIDBAMFieldName]; }
        }

        public const string BusinessIDBAMFieldName = "BusinessID";

        public int LineNumber
        {
            set { _activityItemHashtable.Add(LineNumberBAMFieldName, value); }
            get { return (int)_activityItemHashtable[LineNumberBAMFieldName]; }
        }

        public const string LineNumberBAMFieldName = "LineNumber";

        public const string ActivityName = "EdiBusinessContext";
        private string _EdiBusinessContextID = null;
        private Hashtable _activityItemHashtable = new Hashtable();
    }

    #endregion
}
